import {fromJS} from 'immutable'
import * as constans from './constans'
const defaultState=fromJS({
    topicList:[],
    articleList:[],
    articPage:1,
    RecommerList:[],
    showScroll:false,
    Writer:[],
    popover:false
})


export default (state=defaultState,action)=>{
    switch(action.type){
        case constans.CHANGE_HEOM_DATA :
            return state.merge({
                topicList:fromJS(action.topicList),
                articleList:fromJS(action.articleList),
                RecommerList:fromJS(action.RecommerList),
                Writer:fromJS(action.writer)
            })
        case constans.ADD_HOME_LIST:
            return state.merge({
                articleList:state.get('articleList').concat(action.list),
                articPage:action.page
            })
        case constans.TOGGLE_SHOW:
            return state.set('showScroll',action.show)
        case constans.POPOVER_SHOW:
            return state.set('popover',true)
        case constans.POPOVER_HIDE:
            return state.set('popover',false)
        default:
        return state
    }
    
}

